package com.xncoding.design.JianTingQi;


public class MonitorCenter {
    private AlarmListener remindListener;

    public void connect() {
        // connect...
        String alarmId = "connect_alarm_01";
        String alarmName = "报警器01";
        if (remindListener != null) {
            remindListener.onConnect(new ConnectedEvent(alarmId, alarmName));
        }
        System.out.println("connect success");
    }

    public void disconnect() {
        // disconnected
        String alarmId = "disconnect_alarm_01";
        String alarmName = "报警器01";
        if (remindListener != null) {
            remindListener.onDisConnect(new DisConnectedEvent(alarmId, alarmName));
        }
        // add monitor info
    }

    public void addListener(AlarmListener listener) {
        remindListener = listener;
    }

    public static void main(String[] args) {
        MonitorCenter child = new MonitorCenter();
        child.addListener(new DefaultAlarmListener());
        child.connect();

        child.disconnect();
    }
}

